<?php
namespace Home\Controller;
use Think\Controller;
class BbslistController extends Controller {
    public function index(){
		$cityName = empty($_GET['city'])?'上海':$_GET['city'];
		$city = iconv('UTF-8', 'GBK', $cityName);
		// echo $city;
		$url = 'http://php.weather.sina.com.cn/xml.php?city='.$city.'&password=DJOYnieT8234jlsK&day=0';

		//curl  初始化
		$curl = curl_init();
		// var_dump($curl);

		//URL设置
		curl_setopt($curl, CURLOPT_URL, $url);

		//将curl_exec()  获取的信息以文件流的形式返回,而不是输出
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

		// 执行curl
		$data = curl_exec($curl);

		//关闭 curl
		curl_close($curl);

		//处理xml 返回对象
		$obj =simplexml_load_string($data);
		// var_dump($obj);

		$this->assign('obj',$obj);

		//公告
		$data=M('notice')->select();
       	$this->assign('list',$data);
		        $this->display('Bbslist/Index');

    }
}